<?php
/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2023/9/26 14:54
 * Desc:
 */

/**
 * @method static api_v2($name, $arguments = array())
 */
class Util_CacheKey
{
    /**
     * 静态调用规则, 调用 Util_CacheKey::typeFooBar(1, 'b'); 则返回：type_foo_bar_1_b
     * 函数传参将作为key的后缀，没有后缀则不必传参
     * @param $name
     * @param array $arguments
     * @return string
     */
    public static function __callStatic($name, array $arguments = array())
    {
        foreach ($arguments as $argument) {
            $name .= '_' . $argument;
        }
        return $name;
    }

    /**
     * 生成arguments
     * @param array $params
     * @return void
     */
    public static function make_arguments(array $params): string
    {
        unset($params['mid']);
        unset($params['is_direct']);
        unset($params['token']);
        unset($params['method']);

        return implode('_', $params);
    }
}